package com.ruiysoft.sms.util;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class AliyunSdk
{
    public static IAcsClient getInstance()
    {
        return IAcsClientInstance.client;
    }

    public static CommonRequest assembleRequest(MethodType method, String action, String templateCode, String SignName, String phoneNumber, String vCode)
    {
        CommonRequest request = new CommonRequest();

        request.setMethod(method);
        request.setDomain("dysmsapi.aliyuncs.com");

        request.setVersion("2017-05-25");
        request.setAction(action);
        request.putQueryParameter("PhoneNumbers", phoneNumber);
        request.putQueryParameter("TemplateCode", templateCode);
        request.putQueryParameter("TemplateParam", String.format("{\"remark\":\"%s\"}", new Object[] { vCode }));
        request.putQueryParameter("SignName", SignName);
        return request;
    }

    private static class IAcsClientInstance
    {
        private static final DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAIbEq2a6mEvjFJ", "nzhLeXnjcaJCQCKqozy0Mo5cXH61Zq");
        private static final IAcsClient client = new DefaultAcsClient(profile);
    }
}